From: Florian Müllner Date: Sun, 24 Dec 2023 10:11:14 +0000 (+0100) Subject: animation: Save file and dimensions in properties X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~281^2~2^2~202 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=74445249db7c0df9e582a60f2f15401b7f2c7267;p=gnome-shell.git animation: Save file and dimensions in properties The properties passed to the constructor are currently used directly in anonymous functions. Store them in properties instead, so they become accessible outside the constructor, including for changing them. Part-of: --- diff --git a/js/ui/animation.js b/js/ui/animation.js index c300c841f..85b4d5d73 100644 --- a/js/ui/animation.js +++ b/js/ui/animation.js @@ -21,14 +21,20 @@ class Animation extends St.Bin { style: `width: ${width}px; height: ${height}px;`, }); + this._file = file; + this._width = width; + this._height = height; + this.connect('destroy', this._onDestroy.bind(this)); this.connect('resource-scale-changed', - this._loadFile.bind(this, file, width, height)); + () => this._loadFile()); themeContext.connectObject('notify::scale-factor', () => { - this._loadFile(file, width, height); - this.set_size(width * themeContext.scale_factor, height * themeContext.scale_factor); + this._loadFile(); + this.set_size( + this._width * themeContext.scale_factor, + this._height * themeContext.scale_factor); }, this); this._speed = speed; @@ -38,7 +44,7 @@ class Animation extends St.Bin { this._timeoutId = 0; this._frame = 0; - this._loadFile(file, width, height); + this._loadFile(); } play() { @@ -62,7 +68,7 @@ class Animation extends St.Bin { this._isPlaying = false; } - _loadFile(file, width, height) { + _loadFile() { const resourceScale = this.get_resource_scale(); let wasPlaying = this._isPlaying; @@ -74,7 +80,8 @@ class Animation extends St.Bin { let textureCache = St.TextureCache.get_default(); let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor; - this._animations = textureCache.load_sliced_image(file, width, height, + this._animations = textureCache.load_sliced_image(this._file, + this._width, this._height, scaleFactor, resourceScale, () => this._loadFinished()); this._animations.set({